Page({

  /**
   * 页面的初始数据
   */
  data: {
    searchCont: "",
    tabdex: "",
    popshow: false,
    tablist: [
      {
        types: "综合排序",
        list: [
          { items: "综合排序", checked: false },
          { items: "回答次数", checked: false },
          { items: "星级评分", checked: false },
          { items: "响应时间", checked: false },
          { items: "价格从低到高", checked: false },
          { items: "价格从高到低", checked: false },
        ]
      }, {
        types: "筛选",
        list: [
          {
            items: "价格区间",
            section: [
              { items: "10-19", checked: false },
              { items: "20-29", checked: false },
              { items: "30-50", checked: false },
              { items: "50以上", checked: false },
            ]
          },
          {
            items: "医生职称",
            section: [
              { items: "医师", checked: false },
              { items: "主治医师", checked: false },
              { items: "副主任医师", checked: false },
              { items: "主任医师", checked: false },
            ]
          },
        ]
      },
    ],
  },

  getSearch: function (e) {
    this.setData({
      searchCont: e.detail.value
    })
  },
  // tab切换
  tabbtn(e) {
    if (e.currentTarget.dataset.dex === this.data.tabdex) {
      this.setData({
        popshow: false,
        tabdex: "",
      })
    } else {
      this.setData({
        popshow: true,
        tabdex: e.currentTarget.dataset.dex,
      })
    }
  },
  // tab选项
  itemchecked(e) {
    let arrs = this.data.tablist, i = this.data.tabdex, dex = e.currentTarget.dataset.dex
    arrs[i].list.map(item => {
      item.checked = false
    })
    arrs[i].types = arrs[i].list[dex].items
    arrs[i].list[dex].checked = true
    this.setData({
      tablist: arrs,
      popshow: false,
      tabdex: ""
    })
  },
  // 筛选
  typesclick(e) {
    let datas = this.data;
    let i = e.currentTarget.dataset.index
    let dex = e.currentTarget.dataset.dex
    datas.tablist[datas.tabdex].list[i].section.map(function (item) {
      item.checked = false
    })
    datas.tablist[datas.tabdex].list[i].section[dex].checked = true
    this.setData({
      tablist: datas.tablist
    })
  },
  // 重置
  resultclick() {
    let datas = this.data.tablist;
    for (let i = 0; i < datas[2].list.length; i++) {
      let items = datas[2].list[i].section;
      for (let j = 0; j < items.length; j++) {
        items[j].checked = false
      }
    }
    this.setData({ tablist: datas })
  },
  // 完成
  submitclick() {
    this.setData({
      popshow: false,
      tabdex: ""
    })
  },
  navigator(e) {
    wx.navigateTo({
      url: '/hyb_yl/backstageLife/pages/daozhenxinxi/daozhenxinxi'
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})